//
//  BrandDetailViewController.m
//  SYiDaiy
//
//  Created by dllo on 16/9/8.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "BrandDetailViewController.h"
#import "TAMacro.h"
#import "CustomWebview.h"
@interface BrandDetailViewController ()<UICollectionViewDataSource>

@end

@implementation BrandDetailViewController
#pragma mark -------视图加载
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.navigationController.navigationBar.hidden = NO;
    UICollectionViewFlowLayout *flow = [UICollectionViewFlowLayout new];
    UICollectionView *collection = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - 64 - 49) collectionViewLayout:flow];
    [collection setDataSource:self];
    [collection setPagingEnabled:YES];
    collection.bounces = YES;
    
    CGPoint point = CGPointMake(SCREEN_WIDTH * _rowValue, 44);
    [collection setContentOffset:point];
    
    [flow setScrollDirection:UICollectionViewScrollDirectionHorizontal];
    
    CGSize size = CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT - 64 - 49);
    [flow setItemSize:size];
    
    [flow setMinimumInteritemSpacing:0];
    [flow setMinimumLineSpacing:0];
    flow.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
    
    
    [[self view]addSubview:collection];
    
    
    Class class = [UICollectionViewCell class];
    [collection registerClass:class forCellWithReuseIdentifier:@"BrandDetailViewCell"];
    
//    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:self action:nil];
    
    
}
#pragma mark ----集合视图返回collectioncell的方法
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    NSInteger row = [indexPath row];
    
    NSString *link_share = [_link_shareArray objectAtIndex:row];
    CustomWebview *webview = [[CustomWebview alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - 49 - 64)];
    [webview passStr:link_share];
    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"BrandDetailViewCell" forIndexPath:indexPath];
//    [cell setBackgroundColor:[UIColor redColor]];

    
    
    [cell addSubview:webview];
    
    return cell;
}
#pragma mark ---集合视图item的个数
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    NSInteger count = [_link_shareArray count];
    return count;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
